<template>
	<!-- 自定义头部 -->
	<view>
		<view class="status-bar" :style="'height:'+menuButtonInfo.top+'px'"></view>
		<!-- 页面顶部 -->
		<view class="head" :style="'top:'+menuButtonInfo.top+'px'">
			<view :style="'height:'+menuButtonInfo.height+'px;line-height:'+menuButtonInfo.height+'px'" class="title one-overflow">title</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:'Header',
		data() {
			return {
				menuButtonInfo:{},//右上角胶囊信息
				pages_length:0,//页面栈长度
			}
		},
		props:{
			title:{type:String,default:''},
		},
		onShow() {
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			this.pages_length = getCurrentPages().length
		},
		methods: {
			// 点击返回上一页
			backClick(){
				uni.navigateBack()
			},
			// 点击跳转首页
			homeClick(){
				uni.reLaunch({
					url:'../src/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
// 自定义头部
.status-bar{
	width: 100%;
	background: #fff;
	z-index: 999;
	position: fixed;
	left: 0;
	top: 0;
}
.head{
	position: fixed;
	left: 0;
	width: 100%;
	z-index: 999;
	background: #FFFFFF;
	display: flex;
	justify-content: center;
	padding-bottom: 10rpx;
	.title{
		width: 300rpx;
		color: #000;
		font-size: 28rpx;
		text-align: center;
	}
	.back{
		width: 36rpx;
		height: 36rpx;
		position: absolute;
		left: 20rpx;
		top: 50%;
	}
}
</style>
